@import '../styles/themes/default';

$checkbox: 'snake-checkbox-item';

.#{$checkbox} {
  font-size: $hd * 14;
  font-variant: tabular-nums;
  line-height: $lineHeight;
  color: rgba(0, 0, 0, 0.65);
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  list-style: none;
  cursor: pointer;
  display: inline-block;

  &:hover {
    .#{$checkbox}-select-inner {
      border-color: $brand;
    }
  }

  &-select {
    font-size: $hd * 14;
    font-variant: tabular-nums;
    color: rgba(0, 0, 0, 0.65);
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    list-style: none;
    white-space: nowrap;
    cursor: pointer;
    outline: none;
    display: inline-block;
    line-height: $lineHeight-1;
    position: relative;
    vertical-align: middle;
    top: -0.09em;

    input {
      position: absolute;
      left: 0;
      z-index: 1;
      cursor: pointer;
      opacity: 0;
      top: 0;
      bottom: 0;
      right: 0;
      width: 100%;
      height: 100%;
    }

    &-inner {
      position: relative;
      top: 0;
      left: 0;
      display: block;
      width: 16px;
      height: 16px;
      border: 1px solid #d9d9d9;
      border-radius: 2px;
      background-color: #fff;
      transition: all 0.3s;
      border-collapse: separate;

      &::after {
        transform: rotate(45deg) scale(0);
        position: absolute;
        left: 4.57142857px;
        top: 1.14285714px;
        display: table;
        width: 5.71428571px;
        height: 9.14285714px;
        border: 2px solid #fff;
        border-top: 0;
        border-left: 0;
        content: ' ';
        transition: 0.1s $easeInBack, opacity 0.1s;
        opacity: 0;
      }
    }
  }

  &-label {
    padding: 0 8px;
  }

  &-checked {
    .#{$checkbox}-select-inner {
      background-color: $brand;
      border-color: $brand;

      &::after {
        transform: rotate(45deg) scale(1);
        position: absolute;
        display: table;
        border: 2px solid #fff;
        border-top: 0;
        border-left: 0;
        content: ' ';
        transition: all 0.2s $easeOutBack 0.1s;
        opacity: 1;
      }
    }

    .#{$checkbox}-select {
      &::after {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        border-radius: 2px;
        border: 1px solid $brand;
        content: '';
        animation: antCheckboxEffect 0.36s ease-in-out;
        animation-fill-mode: both;
        visibility: hidden;
      }
    }
  }

  &-indeterminate {
    .#{$checkbox}-select-inner {
      background-color: #fff;
      border-color: #d9d9d9;

      &::after {
        content: ' ';
        transform: translate(-50%, -50%) scale(1);
        border: 0;
        left: 50%;
        top: 50%;
        width: 8px;
        height: 8px;
        background-color: $brand;
        opacity: 1;
      }
    }
  }

  &-disabled {
    .#{$checkbox}-select {
      cursor: not-allowed;
    }

    .#{$checkbox}-select-inner {
      border-color: #d9d9d9 !important;
      background-color: #f5f5f5;

      &::after {
        animation-name: none;
        border-color: #f5f5f5;
        border-collapse: separate;
      }
    }

    &.#{$checkbox}-checked {
      .#{$checkbox}-select-inner {
        &::after {
          animation-name: none;
          border-color: rgba(0, 0, 0, 0.25);
        }
      }
    }
  }

  input[type='checkbox'][disabled] {
    cursor: not-allowed;
  }
}
